#!/usr/local/bin/python3
# *_* coding: UTF-8 *_*
# @IDE: PyCharm
# @Version: Python3.97
# @Author: Kendrick.Kc
# @Email: 509556985@qq.com
# @File: custome_renderer.py
# @Inst: 这里是模块名描述
# @Time: 2023/5/20 18:50
# -----


from rest_framework.renderers import JSONRenderer


# 导入控制返回的JSON格式的类
class CustomJsonRenderer(JSONRenderer):

    # 重构render方法
    def render(self, data=None, accepted_media_type=None, renderer_context=None, code=200, msg='ok'):
        if data is None:
            data = []
        return super().render({
                'msg': msg,
                'code': code,
                'data': data,
            }, accepted_media_type, renderer_context)

